#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main (void)
{
	//定义和初始化字符串
	string s = "hello";
	//string s = string ("hello");
	//string s ("hello");
	cout << s << endl; //hello

	//字符串的连接
	s += " world";
	cout <<  s << endl;//helloworld

	//字符串的拷贝
	string s1 = s;
	cout << s1 << endl;

	//获取字符串中的某个字符
	s[0] = 'H';
	s[6] = 'W';
	cout << s << endl;

	//字符串的比较, 返回的是逻辑值 
	cout << (s == s1) << endl; //0
	cout << (s != s1) << endl; //1
	cout << (s > s1) << endl; //0

	//获取字符串的长度
	cout << s.size() << endl; //11
	cout << s.length() << endl; //11
	//转换为C风格的字符串 
	cout << strlen(s.c_str()) << endl;//11
	return 0;
}

